﻿using System.Collections.Generic;
using Game.modules;
using GameFramework.data;
using GameFramework.properties;
using UnityEngine;

namespace GameFramework.buff
{
    public class PropertyModifierBuff:BaseBuff
    {
        public override void OnIntervalTrigger(List<BaseBuff> ownerAllBuffs)
        {
            if (ownerAllBuffs.Count == 0)
            {
                return;
            }

            PlayerData playerData = ownerAllBuffs[0].holder.GetComponent<PlayerData>();
            //buff变动，从新计算buff属性
            // PropertyManager.Instance.caculatePlayerFuncProperty(playerData,FunctionIds.Buff);
            //属性改变，区分运行时属性改变还是基础属性改变，基础属性改变要重新计算
            Debug.Log("属性变动buff生效:"+times+" 过去时间："+gone+" 变动属性["+buffConfig.values[0]+"]:["+buffConfig.values[1]+"]");
            if (buffConfig.resetOnDestroy)
            {
                speed = buffConfig.values[1];
                EnimyTestCtl enimyCtl = holder.GetComponent<EnimyTestCtl>();
                enimyCtl.speed += speed;
            }
        }

        public override void OnBuffAfterDestroy(List<BaseBuff> ownerAllBuffs)
        {
            if (buffConfig.resetOnDestroy)
            {
                Debug.Log("buff结束，恢复之前的属性");
                EnimyTestCtl enimyCtl = holder.GetComponent<EnimyTestCtl>();
                enimyCtl.speed = speed;
            }
        }
    }
}